package cn.ycc1.baseset.classes;

/**
 * @author ycc
 * @date 2025/3/4
 * Setting the Type of a Variable
 * All variables must have a type. You can use primitive types such as int, float, boolean, etc.
 * Or you can use reference types, such as strings, arrays, or objects.
 *
 * Naming a Variable
 * All variables, whether they are fields, local variables, or parameters, follow the same naming
 * rules and conventions that were covered in the Language Basics section, Variables Naming.
 * In this section, be aware that the same naming rules and conventions are used for method and class names,
 * except that
 * the first letter of a class name should be capitalized, and
 * the first (or only) word in a method name should be a verb.
 */
public class CreatingClasses {
    class MyClass {
        // field, constructor, and
        // method declarations
    }
//    class MyClass extends MySuperClass implements YourInterface {
//        // field, constructor, and
//        // method declarations
//    }

    public class Bicycle {

        // the Bicycle class has
        // three fields
        public int cadence;
        public int gear;
        public int speed;

        // the Bicycle class has
        // one constructor
        public Bicycle(int startCadence, int startSpeed, int startGear) {
            gear = startGear;
            cadence = startCadence;
            speed = startSpeed;
        }

        // the Bicycle class has
        // four methods
        public void setCadence(int newValue) {
            cadence = newValue;
        }

        public void setGear(int newValue) {
            gear = newValue;
        }

        public void applyBrake(int decrement) {
            speed -= decrement;
        }

        public void speedUp(int increment) {
            speed += increment;
        }
    }

    public class MountainBike extends Bicycle {

        // the MountainBike subclass has
        // one field
        public int seatHeight;

        // the MountainBike subclass has
        // one constructor
        public MountainBike(int startHeight, int startCadence,
                            int startSpeed, int startGear) {
            super(startCadence, startSpeed, startGear);
            seatHeight = startHeight;
        }

        // the MountainBike subclass has
        // one method
        public void setHeight(int newValue) {
            seatHeight = newValue;
        }
    }
}
